package com.project.mapper;

import com.project.pojo.Apply;
import com.project.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    /**
     * 增加学生用户
     */
    @Insert("insert into tb_user (id, userId, password, relName, teacherId, number) " +
            "values (null,#{userId},#{password},#{relName},#{teacherId},#{number});")
    void addUser(User user);

    /**
     * 根据id删除学生用户
     */
    @Delete("delete from tb_user where id = #{id};")
    void deleteUser(long id);

    /**
     * 修改学生用户
     */
    @Update("update tb_user set userId = #{userId},password =#{password}," +
            "relName=#{relName},teacherId=#{teacherId},number=#{number} where id = #{id}")
    void updateUser(User user);

    /**
     * 根据信息查询学生用户
     */
    List<User> selectUser(User user);

    /**
     * 查询所有学生用户
     * @return
     */
    List<User> selectAllUser();

    /**
     * 登陆精准验证
     */
    @Select("select * from tb_user where userId = #{userId} and password = #{password};")
    User login(@Param("userId") String userId, @Param("password") String password);

    /**
     * 添加 申请
     * @param apply
     */
    @Insert("insert into tb_apply (id, userId, roomId, timeId, note, applyStatus)" +
            " values (null,#{userId},#{roomId},#{timeId},#{note},#{applyStatus});")
    void addApply(Apply apply);
}
